package com.tgy.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Author: tgy
 * @Date: 12/8/20 3:01 PM
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Person implements Serializable {

    private static final long serialVersionUID = -1046421552172680590L;

    private transient String name;

    private Integer age;

    /**
     * 对写入之前做一些事情
     * @param s
     * @throws java.io.IOException
     */
    private void writeObject(java.io.ObjectOutputStream s)
            throws java.io.IOException{

        s.defaultWriteObject();

        s.writeObject(name);
    }

    /**
     * 读取之前做一些事情
     * @param s
     * @throws java.io.IOException
     * @throws ClassNotFoundException
     */
    private void readObject(java.io.ObjectInputStream s)
            throws java.io.IOException, ClassNotFoundException {

        s.defaultReadObject();
        name = (String) s.readObject();
    }

}
